package com.xian.demo.controller;

import com.xian.demo.mapper.UserMapper;
import com.xian.demo.model.User;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@RestController
public class AjaxController {

    @Resource
    UserMapper userMapper;

    @RequestMapping("insert")
    public void insertUser(String username,String password){
        User user = new User();
        user.setUsername(username);
        user.setPassword(password);
        userMapper.insertUser(user);
    }
    @RequestMapping("showUser")
    public String showUser(String username,String password,Integer k){
        List<User> users = new ArrayList<>();
        for(int i=0;i< k-1;i++){
            User user = new User();
            user.setPassword(password);
            user.setUsername(username);
            user.setUid(i);
            users.add(user);
        }

        return users.toString();
    }

}
